package com.kungfuhacking.wristbandpro.mqtt.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 发送的消息的bean
 * Created by Aaron on 15/12/23.
 */
public class MessageBean implements Parcelable {

    //    public int type;//是发送还是接受
//    public String topicName;//群聊的名称
    //    public String topic;//群聊的topic
    public int isRead;//是否已读

    public String id;

    public String content;//聊天内容 (聊天的内容, 文字的话直接存文字,图片和语音的话存BASE64转的String)
    //    public String contentPath;//聊天内容 (语音,文字, 语音和图片的话就存地址)
    public String sendPic;//发送人的头像
    public String sendName;//发送人的昵称
    public String sendId;//发送人的id
    public String receiveId;//接受者的id
    public String receiveName;//接受者的昵称
    public String receivePic;//接受者的头像
    public String channelId;//topic
    public String messageType;//聊天内容类型,是文本 还是 语音 还是 代办
    public double voiceLength; //语音聊天的时长
    public int chatType;//聊天类型, 单聊还是群聊
    public long sendDate; //发送时间
    public String receiverTime; //接受时间
    public String operationStyle;//操作类型, fragment 页面 用于添加条目 还是删除条目的, 条目点击的时候,是 进入群聊还是单聊
    //    public String cache;//是否需要缓存
//    public int unreadCount;//未读消息条数
    public String qiniuPath;
    public int isListener; // 语音是否已经听过 0表示未读过 1表示已经读过
    public int isReach;
    public boolean showTime; //是否显示时间


    @Override
    public String toString() {
        return "MessageBean{" +
                "isRead=" + isRead +
                ", id='" + id + '\'' +
                ", content='" + content + '\'' +
                ", sendPic='" + sendPic + '\'' +
                ", sendName='" + sendName + '\'' +
                ", sendId='" + sendId + '\'' +
                ", receiveId='" + receiveId + '\'' +
                ", receiveName='" + receiveName + '\'' +
                ", receivePic='" + receivePic + '\'' +
                ", channelId='" + channelId + '\'' +
                ", messageType='" + messageType + '\'' +
                ", voiceLength=" + voiceLength +
                ", chatType=" + chatType +
                ", sendDate=" + sendDate +
                ", receiverTime='" + receiverTime + '\'' +
                ", operationStyle='" + operationStyle + '\'' +
                ", qiniuPath='" + qiniuPath + '\'' +
                ", isListener=" + isListener +
                ", isReach=" + isReach +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.isRead);
        dest.writeString(this.id);
        dest.writeString(this.content);
        dest.writeString(this.sendPic);
        dest.writeString(this.sendName);
        dest.writeString(this.sendId);
        dest.writeString(this.receiveId);
        dest.writeString(this.receiveName);
        dest.writeString(this.receivePic);
        dest.writeString(this.channelId);
        dest.writeString(this.messageType);
        dest.writeDouble(this.voiceLength);
        dest.writeInt(this.chatType);
        dest.writeLong(this.sendDate);
        dest.writeString(this.receiverTime);
        dest.writeString(this.operationStyle);
        dest.writeString(this.qiniuPath);
        dest.writeInt(this.isListener);
        dest.writeInt(this.isReach);
    }

    public MessageBean() {
    }

    protected MessageBean(Parcel in) {
        this.isRead = in.readInt();
        this.id = in.readString();
        this.content = in.readString();
        this.sendPic = in.readString();
        this.sendName = in.readString();
        this.sendId = in.readString();
        this.receiveId = in.readString();
        this.receiveName = in.readString();
        this.receivePic = in.readString();
        this.channelId = in.readString();
        this.messageType = in.readString();
        this.voiceLength = in.readDouble();
        this.chatType = in.readInt();
        this.sendDate = in.readLong();
        this.receiverTime = in.readString();
        this.operationStyle = in.readString();
        this.qiniuPath = in.readString();
        this.isListener = in.readInt();
        this.isReach = in.readInt();
    }

    public static final Parcelable.Creator<MessageBean> CREATOR = new Parcelable.Creator<MessageBean>() {
        @Override
        public MessageBean createFromParcel(Parcel source) {
            return new MessageBean(source);
        }

        @Override
        public MessageBean[] newArray(int size) {
            return new MessageBean[size];
        }
    };
}
